package springboot.listenConsumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import springboot.config.DelayRabbitMQConfig;

import java.io.IOException;
import java.util.Date;

@Slf4j
@Component
public class DelayConsumerListener {
    @RabbitListener(queues = {DelayRabbitMQConfig.DELAY_QUEUE})
    public void receiveDelayMessage(Message message, Channel channel) throws IOException {
        String msg=new String(message.getBody());
        log.info("当前收到消息的时间{},收到的消息为{}",new Date(),msg);
        //channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
